function createMatrixSettings() {
    var component = Qt.createComponent("CreateMatrix.qml");
    if(component != Component.Ready) console.log(component.errorString());
    var dynamic = component.createObject(mainForminMain);
}

function fetchValue(i,j){
    return media.getValue(i,j);
}

function initMatrix(){
    var txt = ""
    for(var i = 0; i < 9; i++){
        for(var j = 0; j < 9; j++){
            txt = txt + fetchValue(i,j) + " ";
        }
        txt = txt + "\n";
    }
    return txt;
}

function verify(s){
    if(isNaN(s)){
        return false;
    } else {
        var i = parseInt(s);
        if(i < 0 || i > 8){
            return false;
        }
    }
    return true;
}

function errorInValid(){
    var component = Qt.createComponent("MyDialog.qml");
    var dynamic = component.createObject(mainForminMain,{"text":"无效输入"});
}

function modify(i,j,s){
    media.setValue(parseInt(i), parseInt(j), parseInt(s));
    textarea.text = initMatrix();
}

function getMatrix(){
    var txt="";
    for(var i = 0; i < 9; i++){
        for(var j = 0; j < 9; j++){
            txt = txt + fetchValue(i,j) + " ";
        }
        txt = txt + "\n";
    }
    return txt;
}

function build(){
    adj_txt.text = media.adj;

    var node = node_txt.text;
    var i = parseInt(node);

    media.buildbfs(i);
    media.builddfs(i);
    bfs_txt.text = media.bfs;
    dfs_txt.text = media.dfs;
}
